<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <style>
        .tab {
            width: 400px;
            height: 300px;
            border: 1px solid #ccc;
            margin: 50px auto;
        }

        ul {
            margin: 0;
            padding: 0;
            height: 50px;
        }

        li {
            cursor: pointer;
            box-sizing: border-box;
            height: 50px;
            width: 100px;
            list-style: none;
            text-align: center;
            line-height: 50px;
            float: left;
            border-right: 1px solid #ccc;
            border-bottom: 1px solid #ccc;
        }

        .active {
            background-color: pink;
        }

        .img {
            display: none;
            height: 250px;
            width: 400px;
        }

        .img img {
            height: 100%;
            width: 100%;
        }

        .current {
            display: block;
        }
    </style>
</head>

<body>
    <div class="tab">
        <ul>
            <li @click='change(index)' :class='currentIndex==index?"active":""' :key='item.id'
                v-for='(item,index) in list'>{{item.title}}</li>

        </ul>
        <div :class='currentIndex==index?"current":""' class="img" :key='item.id' v-for='(item,index) in list'>
            <img :src="item.path" alt="">
        </div>
    </div>
    <script>
        var vm = new Vue({
            el: '.tab',
            data: {
                currentIndex: 0,
                list: [{
                        id: 1,
                        title: 'apple',
                        path: "./apple.png",
                    },
                    {
                        id: 2,
                        title: 'banana',
                        path: "./banana.jpg",
                    },
                    {
                        id: 3,
                        title: 'lemon',
                        path: "./lemon.png",
                    },
                    {
                        id: 4,
                        title: 'orange',
                        path: "./orange.png",
                    }
                ]
            },
            methods: {
                change: function (index) {
                    this.currentIndex = index;
                }
            }
        });
    </script>
</body>

</html>